package site.immonkey.testmvc.beans;

import java.util.HashMap;
import java.util.Map;

public class RespInfo {
    private int status;
    private String message;
    private Map<String, Object> otherInfo;

    public RespInfo() {}

    public RespInfo(int status) {
        this(status, null);
    }

    public RespInfo(int status, String message) {
        this(status, message, null);
    }

    public RespInfo(int status, String message, Map<String, Object> otherInfo) {
        setStatus(status);
        setMessage(message);
        setOtherInfo(otherInfo);
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Map<String, Object> getOtherInfo() {
        return otherInfo;
    }

    public Object getOthreInfo(String name) {
        return otherInfo == null ? null : otherInfo.get(name);
    }

    public void setOtherInfo(Map<String, Object> otherInfo) {
        this.otherInfo = otherInfo;
    }

    public void setOtherInfo(String name, Object info) {
        if (otherInfo == null) otherInfo = new HashMap<>();
        otherInfo.put(name, info);
    }

    @Override
    public String toString() {
        return "RespInfo [status=" + status + ", message=" + message + ", otherInfo="
                + otherInfo + "]";
    }

}
